package com.jh.jingfei.bottom_bar;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;

/**
 * Created by sxb on 2017/7/19.
 */

public class BottomNavigationItem {
    private int mIconResource;
    private Drawable mIcon;

    private int mInactiveIconResource;
    private Drawable mInactiveIcon;
    private boolean active = false;

    private int badge = 0;

    private int mTitleResource;
    private String mTitle;

    private int mActiveColorResource;
    private String mActiveColorCode;
    private int mActiveColor;

    private int mInActiveColorResource;
    private String mInActiveColorCode;
    private int mInActiveColor;


    /**
     * @param mIconResource resource for the Tab icon.
     * @param mTitle        title for the Tab.
     */
    public BottomNavigationItem(@DrawableRes int mIconResource, @NonNull String mTitle) {
        this.mIconResource = mIconResource;
        this.mTitle = mTitle;
    }

    /**
     * @param mIcon  drawable icon for the Tab.
     * @param mTitle title for the Tab.
     */
    public BottomNavigationItem(Drawable mIcon, @NonNull String mTitle) {
        this.mIcon = mIcon;
        this.mTitle = mTitle;
    }

    /**
     * @param mIcon          drawable icon for the Tab.
     * @param mTitleResource resource for the title.
     */
    public BottomNavigationItem(Drawable mIcon, @StringRes int mTitleResource) {
        this.mIcon = mIcon;
        this.mTitleResource = mTitleResource;
    }

    /**
     * @param mIconResource  resource for the Tab icon.
     * @param mTitleResource resource for the title.
     */
    public BottomNavigationItem(@DrawableRes int mIconResource, @StringRes int mTitleResource) {
        this.mIconResource = mIconResource;
        this.mTitleResource = mTitleResource;
    }


    public BottomNavigationItem setIconResource(int mIconResource) {
        this.mIconResource = mIconResource;
        return this;
    }

    public Drawable getIcon(Context context) {
        if (this.mIconResource != 0) {
            return ContextCompat.getDrawable(context, this.mIconResource);
        } else {
            return this.mIcon;
        }
    }

    public BottomNavigationItem setIcon(Drawable mIcon) {
        this.mIcon = mIcon;
        return this;
    }

    public BottomNavigationItem setInactiveIconResource(int mInactiveIconResource) {
        this.mInactiveIconResource = mInactiveIconResource;
        return this;
    }

    public BottomNavigationItem setInactiveIcon(Drawable mInactiveIcon) {
        this.mInactiveIcon = mInactiveIcon;
        return this;
    }


    public int getIconResource() {
        return mIconResource;
    }

    public int getInactiveIconResource() {
        return mInactiveIconResource;
    }

    public Drawable getInactiveIcon(Context context) {
        if (this.mInactiveIconResource != 0) {
            return ContextCompat.getDrawable(context, this.mInactiveIconResource);
        } else {
            return this.mInactiveIcon;
        }
    }

    public boolean isActive() {
        return active;
    }

    public BottomNavigationItem setActive(boolean active) {
        this.active = active;
        return this;
    }

    public BottomNavigationItem setTitleResource(int mTitleResource) {
        this.mTitleResource = mTitleResource;
        return this;
    }

    public String getTitle(Context context) {
        if (mTitleResource != 0) {
            return context.getString(this.mTitleResource);
        }
        return mTitle;
    }

    public BottomNavigationItem setTitle(String mTitle) {
        this.mTitle = mTitle;
        return this;
    }

    public BottomNavigationItem setActiveColorResource(int mActiveColorResource) {
        this.mActiveColorResource = mActiveColorResource;
        return this;
    }

    public int getBadge() {
        return badge;
    }

    public BottomNavigationItem setBadge(int badge) {
        this.badge = badge;
        return this;
    }
}
